package com.yantong.mapper;

import com.yantong.pojo.Balance;
import com.yantong.pojo.vo.DataStatsDto;
import com.yantong.pojo.vo.OrderAchievementVo;
import com.yantong.pojo.vo.StoreSalesStatsVo;
import com.yantong.pojo.vo.UserAchievementVo;
import com.yantong.pojo.Member;
import com.yantong.pojo.MemberExample;
import com.yantong.pojo.vo.CommanerVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public interface MemberMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_member
     *
     * @mbggenerated Tue Sep 11 14:04:24 CST 2018
     */
    int countByExample(MemberExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_member
     *
     * @mbggenerated Tue Sep 11 14:04:24 CST 2018
     */
    int deleteByExample(MemberExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_member
     *
     * @mbggenerated Tue Sep 11 14:04:24 CST 2018
     */
    int deleteByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_member
     *
     * @mbggenerated Tue Sep 11 14:04:24 CST 2018
     */
    int insert(Member record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_member
     *
     * @mbggenerated Tue Sep 11 14:04:24 CST 2018
     */
    int insertSelective(Member record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_member
     *
     * @mbggenerated Tue Sep 11 14:04:24 CST 2018
     */
    List<Member> selectByExample(MemberExample example);

    List<Member> selectByExample(MemberExample example, RowBounds rowBounds);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_member
     *
     * @mbggenerated Tue Sep 11 14:04:24 CST 2018
     */
    Member selectByPrimaryKey(Long id);


    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_member
     *
     * @mbggenerated Tue Sep 11 14:04:24 CST 2018
     */
    int updateByExampleSelective(@Param("record") Member record, @Param("example") MemberExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_member
     *
     * @mbggenerated Tue Sep 11 14:04:24 CST 2018
     */
    int updateByExample(@Param("record") Member record, @Param("example") MemberExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_member
     *
     * @mbggenerated Tue Sep 11 14:04:24 CST 2018
     */
    int updateByPrimaryKeySelective(Member record);

	int updateNull(Map<String, Object> params);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_member
     *
     * @mbggenerated Tue Sep 11 14:04:24 CST 2018
     */
    int updateByPrimaryKey(Member record);
    
    /**
     * 取消打烊 
     * @param record
     * @return
     */
    int cancelCommander(Member record);

    /**
     * 查询会员与粉丝表关联数据条数
     * @param searchMap
     * @return
     */
    int getCountByWhere(HashMap<String, Object> searchMap);

   /**
    * 查询会员与粉丝表关联数据列表,分页
    * @param searchMap
    * @param rowBounds
    * @return
    */
    List<Member> getListByWhere(HashMap<String, Object> searchMap, RowBounds rowBounds);
    
    /**
     * 查询会员与粉丝表关联数据列表
     * @param searchMap
     * @param rowBounds
     * @return
     */
     List<Member> getListByWhere(Map searchMap);
    

    /**
     * 查询会员条数 
     * @param searchMap
     * @return
     */
    int getCountByWhere2(HashMap<String, Object> searchMap);

    /**
     * 查询会员列表,分页 
     * @param searchMap
     * @param rowBounds
     * @return
     */
    List<Member> getListByWhere2(HashMap<String, Object> searchMap, RowBounds rowBounds);
    
    /**
     * 查询会员列表,不分页 
     * @param searchMap
     * @return
     */
    List<Member> getListByWhere2(HashMap<String, Object> searchMap);
    
    /**
     * 查询会员与粉丝表关联数据条数
     * @param searchMap
     * @return
     */
    int getCountByMemberWhere(HashMap<String, Object> searchMap);

    /**
     * 查询会员与粉丝表关联数据列表,不分页
     * @param searchMap
     * @return
     */
    List<Member> getListByMemberWhere(HashMap<String, Object> searchMap);
    
    /**
     * 查询会员与粉丝表关联数据列表,分页
     * @param searchMap
     * @param rowBounds
     * @return
     */
    List<Member> getListByMemberWhere(HashMap<String, Object> searchMap, RowBounds rowBounds);
    
    /**
     * 查询会员与商品表关联数据列表,不分页
     * @param searchMap
     * @return
     */
    List<Member> getComCommodityStatistics(HashMap<String, Object> searchMap);
    
    /**
     * 查询会员与商品表关联数据列表,分页
     * @param searchMap
     * @param rowBounds
     * @return
     */
    List<Member> getComCommodityStatistics(HashMap<String, Object> searchMap, RowBounds rowBounds);

    /**
     * 根据会员openId获取会员详情
     * @param openId
     * @return
     */
    Member getByOpenId(@Param("openId") String openId);

    /**
     * 根据会员openId获取会员详情
     * @param openId
     * @return
     */
    Member getByAppOpenId(@Param("openId") String openId);

	/**
	 * 根据公众号openId获取会员详情
	 * @param openPublicId
	 * @return
	 */
	Member getByOpenPublicId(@Param("openPublicId") String openPublicId);

    /**
     * 获取附近门店列表
     * @param params
     * @param rowBounds
     * @return
     */
    List<Member> getNearCommanders(Map<String, Object> params, RowBounds rowBounds);

    /**
     * 获取附近门店列表
     * @param params
     * @param rowBounds
     * @return
     */
    List<Member> getNewNearCommanders(Map<String, Object> params, RowBounds rowBounds);

    /**
     * 条件查询余额列表
     * @param params
     * @param rowBounds
     * @return
     */
    List<Balance> listBalancesByParams(Map<String, Object> params, RowBounds rowBounds);

    /**
     * 条件查询余额列表 不分页
     * @param params
     * @return
     */
    List<Balance> listBalancesByParams(Map<String, Object> params);

    /**
     * 条件统计余额数
     * @param params
     * @return
     */
    int countBalanceByParams(Map<String, Object> params);

    /**
     * 条件统计余额总和
     * @param params
     * @return
     */
    Double getBalanceSum(Map<String, Object> params);

    /**
     * 会员余额详情
     * @param mid
     * @return
     */
    Balance getBalanceDetail(Long mid);

    /**
     * 余额充值
     * @param mid
     * @param money
     * @return
     */
    int rechargeBalance(@Param("mid") Long mid, @Param("money") Double money);

    /**
     * 统计门店下会员数
     * @param tmid 门店ID
     * @param queryItem 查询关键词
     * @return
     */
    int countTeamMembers(@Param("tmid") Long tmid, @Param("queryItem") String queryItem);

    /**
     * 获取门店下会员列表
     * @param tmid
     * @param queryItem
     * @param rowBounds
     * @return
     */
    List<Member> listTeamMembers(@Param("tmid") Long tmid, @Param("queryItem") String queryItem, RowBounds rowBounds);

    /**
     * 统计新增会员
     * @param start
     * @param end
     * @param centreId
     * @return
     */
    int countNewByTime(@Param("start") Date start, @Param("end") Date end, @Param("centreId") Long centreId);

    /**
     * 获取时间段类 每日新增会员数
     * @param start
     * @param end
     * @param centreId
     * @return
     */
    List<Map<String,Object>> getMemberTrend(@Param("start") Date start, @Param("end") Date end, @Param("centreId") Long centreId);

    /**
     * 查看未分配小区条数
     * @param searchMap
     * @return
     */
    int getCountUnallocatedXiaoQu(HashMap<String, Object> searchMap);

    /**
     * 查看未分配小区
     * @param searchMap
     * @param rowBounds
     * @return
     */
    List<Member> getUnallocatedXiaoQu(HashMap<String, Object> searchMap, RowBounds rowBounds);

    /**
     * 寻找下级门店
     * @param upTeamid
     * @return
     */
    List<Member> getSubordinate(Long upTeamid);

    /**
     * 更新上级门店
     * @param record
     * @return
     */
    int updateByUpTeamid(Member record);

    /**
     * 查询网点单数据
     * @param searchMap
     * @return
     */
    List<Member> listWdian(HashMap<String, Object> searchMap);


    /**
     * 统计合作门店数
     * @param param
     * @return
     */
    int countTeamCommanders(Map<String, Object> param);

    /**
     * 合作门店列表
     * @param params
     * @param rowBounds
     * @return
     */
    List<Member> listTeamCommanders(Map<String, Object> params, RowBounds rowBounds);

    /**
     * 通过会员编号查询到绑定门店
     * @param memberId
     * @return
     */
	CommanerVo getCommanderByMembId(Long memberId);
	/**
	 * 查询供应商余额信息
	 */
	Balance getSupllyBalanceDetail(Long mid);

	/**
	 * 得到门店下面的用户
	 * @param params
	 * @param rowBounds
	 * @return
	 */
	List<Member> getTeamtheUserByMid(Map<String, Object> params, RowBounds rowBounds);

	/**
	 * 得到门店下面的用户
	 * @param params
	 * @param rowBounds
	 * @return
	 */
	List<Member> getTeamtheUserByMid(Map<String, Object> params);

	/**
	 * 总页数
	 * @param params
	 * @return
	 */
	int countTotal(Map<String, Object> params);

	/**
	 * 门店修改站点修改门店下的用户的站点Id
	 * @param params
	 * @return
	 */
	List<Member> getTeamUnderMeberById(Map<String, Object> params);

	/**
	 * 修改用户门店下用户的站点Id
	 * @return
	 */
	int updateMeberById(Map<String, Object> params);

	/**
	 * 得到所有角色余额
	 * @return
	 */
	String getAllRoleSumMoney();



    Member getByUnionId(@Param("unionId") String unionId);

	/**
	 * 商户推荐人
	 * @return
	 */
	List<Member> getMemberByReferrals(Map<String, Object> map);

	int getMemberAndRole(Map<String, Object> map);

	/**
	 * 修改把推荐人为空
	 * @param mid
	 * @return
	 */
	int updteamIsNull(@Param("mid") Long mid);

    /**
     *根据centerId查询团长
     * @param centerId
     * @return
     */
    List<Member> getTeamListByCenterId(Long centerId);

    List<Member> getListByCenterId(Long centerId);

    Member getByMobilePwd(@Param("mobile") String mobile, @Param("pwd") String encPassword, @Param("centerId") Long centerId);

    Member getByMobile(String mobile);

    Member getByMobileCenter(@Param("mobile") String mobile, @Param("centerId") Long centerId);

    Member selectByAdminUser(@Param("adminUser") String adminUser);

    int queryTotal(Map<String, Object> param);
    List<Member> pageListBycondition(Map<String, Object> param, RowBounds rowBounds);

    int updateClerkByTeamid(Member record);

    String getCountByMemberByMid(Long mid);
    String getCountByMemberByMidBuy(Long mid);
    List<Member> getTeamMemberByMid(Long mid);

    /**
     * 获取本地生活的店铺列表
     * @param paramMap
     * @return
     */
    List<Member> getLocalLifShop(Map<String, Object> paramMap, RowBounds rowBounds);

    int getLocalLifShopCount(Map<String, Object> paramMap, RowBounds rowBounds);

    /**
     *  根据mid查找用户信息
     *
     * @param [mid]
     * @return com.jz.user.domain.Member
     * @author hs
     * @date 2021/1/7 11:43
     */
    Member selectByMid(int mid);

    /**
     *  更新用户的红包余额
     *
     * @param
     * @return int
     * @author huangshuai
     * @date 2021/1/8 11:24
     */
    int updateRedENvelopeByMid(Member member);


    int updateCredit2ByMid(Member member);

    Member selectCdkSendLimitByPrimaryKey(Long mid);

	Member selectByCentreIdAndIsHeadOffice(@Param("centreId") Long centreId, @Param("isHeadOffice") int isHeadOffice);

	List<Member> myRecommendMemberList(Long userid);

    StoreSalesStatsVo getStoreItemSalesStatsSum(DataStatsDto dataStatsDto);

    List<StoreSalesStatsVo> getStoreItemSalesStats(DataStatsDto dataStatsDto);

    Integer getUserachievementDataCount(DataStatsDto dataStatsDto);

    List<UserAchievementVo> getUserachievementData(DataStatsDto dataStatsDto, RowBounds rowBounds);

    @MapKey("mid")
    Map<Long, OrderAchievementVo> getUserSelfStats(Map map);
    @MapKey("mid")
    Map<Long,OrderAchievementVo>  getUserShareStats(Map map);

    List<UserAchievementVo> getTeamAchievementStats(DataStatsDto dataStatsDto);

    List<UserAchievementVo> getRoleAchievementStats(DataStatsDto dataStatsDto);

    Integer getCentreAchievementStatsCount(DataStatsDto dataStatsDto);
    List<UserAchievementVo> getCentreAchievementStats(DataStatsDto dataStatsDto);
    List<UserAchievementVo> getCentreAchievementStats(DataStatsDto dataStatsDto, RowBounds rowBounds);

    /**
     * 根据centerId获得平台的 ShopMemberId (门店id)
     * @param centerId
     * @return
     */
    Long getCenterIdByShopMemberId(Long centerId);

    /**
     * 根据shopMemberId 获得 centerId
     * @param shopMemberId
     * @return
     */
    Long getShopMemberIdByCenterId(Long shopMemberId);

    Member getOneByCentreIdAndMobile(@Param("centreId") Long centreId, @Param("loginMobile") String loginMobile);
}